Skip to contentSkip to conversation

Change in openvpn[master]: ssl_ncp: Avoid conversion warning in replace_default_in_ncp_ciphers_o...

Openvpn-devel In review flichtenheld (Code Review) 3 participants 6 messages Dec 19, 2025 – Jan 24 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): gerrit.1766154731000.I380e842b7429060d13bc0264e55fa5c06ab427df@...2715...

#1 lore raw

Attention is currently required from: plaisthos.

Hello plaisthos,

I'd like you to do a code review.
Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1452?usp=email

to review the following change.

Change subject: ssl_ncp: Avoid conversion warning in replace_default_in_ncp_ciphers_option
......................................................................

ssl_ncp: Avoid conversion warning in replace_default_in_ncp_ciphers_option

Change-Id I380e842b7429060d13bc0264e55fa5c06ab427df

---
M src/openvpn/ssl_ncp.c

1 file changed, 3 insertions(+), 11 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/52/1452/1

src/openvpn/ssl_ncp.c +3 -11
index d4519b0..06262fe 100644
@@ -534,11 +534,6 @@
     }
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wconversion"
-#endif
-
 /**
  * Replaces the string DEFAULT with the string \c replace.
  *
@@ -549,12 +544,13 @@
 replace_default_in_ncp_ciphers_option(struct options *o, const char *replace)
 {
     const char *search = "DEFAULT";
-    const int ncp_ciphers_len = strlen(o->ncp_ciphers) + strlen(replace) - strlen(search) + 1;
+    const size_t ncp_ciphers_len = strlen(o->ncp_ciphers) + strlen(replace) - strlen(search) + 1;
 
     uint8_t *ncp_ciphers = gc_malloc(ncp_ciphers_len, true, &o->gc);
 
     struct buffer ncp_ciphers_buf;
-    buf_set_write(&ncp_ciphers_buf, ncp_ciphers, ncp_ciphers_len);
+    ASSERT(ncp_ciphers_len <= INT_MAX);
+    buf_set_write(&ncp_ciphers_buf, ncp_ciphers, (int)ncp_ciphers_len);
 
     const char *def = strstr(o->ncp_ciphers, search);
 
@@ -571,10 +567,6 @@
     o->ncp_ciphers = (char *)ncp_ciphers;
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
-
 /**
  * Checks for availibility of Chacha20-Poly1305 and sets
  * the ncp_cipher to either AES-256-GCM:AES-128-GCM or

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1452?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I380e842b7429060d13bc0264e55fa5c06ab427df
Gerrit-Change-Number: 1452
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>

#2 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld.

plaisthos has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1452?usp=email )

Change subject: ssl_ncp: Avoid conversion warning in replace_default_in_ncp_ciphers_option
......................................................................

Patch Set 1: Code-Review+2

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1452?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I380e842b7429060d13bc0264e55fa5c06ab427df
Gerrit-Change-Number: 1452
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Thu, 22 Jan 2026 12:46:55 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes

#3 lore raw

PATCH 1/1 ssl_ncp: Avoid conversion warning in replace_default_in_ncp_ciphers_option

In reply to a message not in the archive
Change-Id I380e842b7429060d13bc0264e55fa5c06ab427df

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1452
---

This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1452
This mail reflects revision 1 of this Change.

Acked-by according to Gerrit (reflected above):
Arne Schwabe <[email protected]...>

src/openvpn/ssl_ncp.c +3 -11
index d4519b0..06262fe 100644
@@ -534,11 +534,6 @@
     }
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wconversion"
-#endif
-
 /**
  * Replaces the string DEFAULT with the string \c replace.
  *
@@ -549,12 +544,13 @@
 replace_default_in_ncp_ciphers_option(struct options *o, const char *replace)
 {
     const char *search = "DEFAULT";
-    const int ncp_ciphers_len = strlen(o->ncp_ciphers) + strlen(replace) - strlen(search) + 1;
+    const size_t ncp_ciphers_len = strlen(o->ncp_ciphers) + strlen(replace) - strlen(search) + 1;
 
     uint8_t *ncp_ciphers = gc_malloc(ncp_ciphers_len, true, &o->gc);
 
     struct buffer ncp_ciphers_buf;
-    buf_set_write(&ncp_ciphers_buf, ncp_ciphers, ncp_ciphers_len);
+    ASSERT(ncp_ciphers_len <= INT_MAX);
+    buf_set_write(&ncp_ciphers_buf, ncp_ciphers, (int)ncp_ciphers_len);
 
     const char *def = strstr(o->ncp_ciphers, search);
 
@@ -571,10 +567,6 @@
     o->ncp_ciphers = (char *)ncp_ciphers;
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
-
 /**
  * Checks for availibility of Chacha20-Poly1305 and sets
  * the ncp_cipher to either AES-256-GCM:AES-128-GCM or
#4 lore raw

[Openvpn-devel] [PATCH applied] Re: ssl_ncp: Avoid conversion warning in replace_default_in_ncp_ciphers_option

Change makes sense, has an ACK from Arne (who authored most of this code), and passes BB tests. One #pragma pair gone, in it goes :-)

Your patch has been applied to the master branch.

commit b28321edfe65290fae6d09d931aa36187ad95e95

Author: Frank Lichtenheld
Date:   Thu Jan 22 13:58:28 2026 +0100
     ssl_ncp: Avoid conversion warning in replace_default_in_ncp_ciphers_option

     Signed-off-by: Frank Lichtenheld <[email protected]...>
     Acked-by: Arne Schwabe <[email protected]...>
     Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1452
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg35391.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#5 lore raw
In reply to a message not in the archive

cron2 has uploaded a new patch set (#2) to the change originally created by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1452?usp=email )

The following approvals got outdated and were removed:
Code-Review+2 by plaisthos

Change subject: ssl_ncp: Avoid conversion warning in replace_default_in_ncp_ciphers_option
......................................................................

ssl_ncp: Avoid conversion warning in replace_default_in_ncp_ciphers_option

Change-Id I380e842b7429060d13bc0264e55fa5c06ab427df

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1452
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg35391.html

---
M src/openvpn/ssl_ncp.c

1 file changed, 3 insertions(+), 11 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/52/1452/2

src/openvpn/ssl_ncp.c +3 -11
index 1a2405c..20fd2f0 100644
@@ -534,11 +534,6 @@
     }
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wconversion"
-#endif
-
 /**
  * Replaces the string DEFAULT with the string \c replace.
  *
@@ -549,12 +544,13 @@
 replace_default_in_ncp_ciphers_option(struct options *o, const char *replace)
 {
     const char *search = "DEFAULT";
-    const int ncp_ciphers_len = strlen(o->ncp_ciphers) + strlen(replace) - strlen(search) + 1;
+    const size_t ncp_ciphers_len = strlen(o->ncp_ciphers) + strlen(replace) - strlen(search) + 1;
 
     uint8_t *ncp_ciphers = gc_malloc(ncp_ciphers_len, true, &o->gc);
 
     struct buffer ncp_ciphers_buf;
-    buf_set_write(&ncp_ciphers_buf, ncp_ciphers, ncp_ciphers_len);
+    ASSERT(ncp_ciphers_len <= INT_MAX);
+    buf_set_write(&ncp_ciphers_buf, ncp_ciphers, (int)ncp_ciphers_len);
 
     const char *def = strstr(o->ncp_ciphers, search);
 
@@ -571,10 +567,6 @@
     o->ncp_ciphers = (char *)ncp_ciphers;
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
-
 /**
  * Checks for availibility of Chacha20-Poly1305 and sets
  * the ncp_cipher to either AES-256-GCM:AES-128-GCM or

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1452?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I380e842b7429060d13bc0264e55fa5c06ab427df
Gerrit-Change-Number: 1452
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>

#6 lore raw
In reply to a message not in the archive

cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1452?usp=email )

Change subject: ssl_ncp: Avoid conversion warning in replace_default_in_ncp_ciphers_option
......................................................................

ssl_ncp: Avoid conversion warning in replace_default_in_ncp_ciphers_option

Change-Id I380e842b7429060d13bc0264e55fa5c06ab427df

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1452
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg35391.html

---
M src/openvpn/ssl_ncp.c

1 file changed, 3 insertions(+), 11 deletions(-)
src/openvpn/ssl_ncp.c +3 -11
index 1a2405c..20fd2f0 100644
@@ -534,11 +534,6 @@
     }
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wconversion"
-#endif
-
 /**
  * Replaces the string DEFAULT with the string \c replace.
  *
@@ -549,12 +544,13 @@
 replace_default_in_ncp_ciphers_option(struct options *o, const char *replace)
 {
     const char *search = "DEFAULT";
-    const int ncp_ciphers_len = strlen(o->ncp_ciphers) + strlen(replace) - strlen(search) + 1;
+    const size_t ncp_ciphers_len = strlen(o->ncp_ciphers) + strlen(replace) - strlen(search) + 1;
 
     uint8_t *ncp_ciphers = gc_malloc(ncp_ciphers_len, true, &o->gc);
 
     struct buffer ncp_ciphers_buf;
-    buf_set_write(&ncp_ciphers_buf, ncp_ciphers, ncp_ciphers_len);
+    ASSERT(ncp_ciphers_len <= INT_MAX);
+    buf_set_write(&ncp_ciphers_buf, ncp_ciphers, (int)ncp_ciphers_len);
 
     const char *def = strstr(o->ncp_ciphers, search);
 
@@ -571,10 +567,6 @@
     o->ncp_ciphers = (char *)ncp_ciphers;
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
-
 /**
  * Checks for availibility of Chacha20-Poly1305 and sets
  * the ncp_cipher to either AES-256-GCM:AES-128-GCM or

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1452?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I380e842b7429060d13bc0264e55fa5c06ab427df
Gerrit-Change-Number: 1452
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>